﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace MediaBrowserSL.BOL
{
    [DataContract]
    public class Media : BaseItem
    {
        #region Private
        private String name;
        private String description;
        private String urlImage;
        private String urlContent;
        private double size;
        #endregion

        [DataMember]
        public int Id { get; set; }

        [DataMember]
        public String Name
        {
            get
            {
                return name;
            }
            set
            {
                name = value;
                OnPropertyChanged("Name");
            }
        }

        [DataMember]
        public String Description
        {
            get
            {
                return description;
            }
            set
            {
                if (value != null)
                {
                    description = value;
                }
                else
                {
                    description = "";
                }
                OnPropertyChanged("Description");
            }
        }

        [DataMember]
        public DateTime CreationDate { get; set; }

        [DataMember]
        public String UrlImage
        {
            get
            {
                return urlImage;
            }
            set
            {
                urlImage = value;
                OnPropertyChanged("UrlImage");
            }
        }

        [DataMember]
        public String UrlContent
        {
            get
            {
                return urlContent;
            }
            set
            {
                urlContent = value;
                OnPropertyChanged("UrlContent");
            }
        }

        [DataMember]
        public double Size
        {
            get
            {
                return size;
            }
            set
            {
                size = value;
                OnPropertyChanged("Size");
            }
        }

        [DataMember]
        public Category Category { get; set; }

        [DataMember]
        public List<Media> MediaItems { get; set; }

        [DataMember]
        public Media MediaParent { get; set; }

        [DataMember]
        public User User { get; set; }

        public Media()
        {
            MediaItems = new List<Media>();
        }

        public Media(int id, String name, DateTime CreationDate, String description, Category category,
                     String urlImage, String urlContent, User user)
        {
            this.Id = id;
            this.Name = name;
            this.Description = description;
            this.CreationDate = CreationDate;
            this.UrlImage = urlImage;
            this.UrlContent = urlContent;
            this.Category = category;
            this.User = user;
            MediaItems = new List<Media>();
        }
    }
}
